/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.audit.service.plugins  
 */
package com.apache.audit.service.plugins;

import java.util.List;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.audit.entity.LogModelDetail;
import com.apache.audit.manager.LogModelDetailManager;
import com.apache.cache.util.Validator;
import com.apache.database.model.Page;

/**
 * description:  模型属性列表
 * @author dyhou 创建时间：2016-7-11  
 */
public class LogModelDetailListPluginImpl implements PluginConnector {

	private LogModelDetailManager logModelDetailManager;

	/**
	 * TODO 简单描述该方法的实现功能（可选）.  
	 * 参数:modelId  
	 */
	public Object execute(ParamsVo param) throws Exception {
		ResultEntity entity = new ResultEntity();
		entity.setResult("true");
		String modelId = String.valueOf(param.getParams("modelId"));
		if (Validator.isNull(modelId)) {
			entity.setMessage("缺少方法参数");
		}
		ParamsVo<LogModelDetail> vo = new ParamsVo<LogModelDetail>();
		LogModelDetail model = new LogModelDetail();
		model.setModelId(modelId);
		vo.setObj(model);
		vo.setMethodKey("ByService");
		String rows = Validator.getDefaultStr(String.valueOf(param.getParams("rows")), "0");
		if ("0".equals(rows)) {
			List list = logModelDetailManager.getList(vo);
			entity.setEntity(list);
		} else {
			String page = Validator.getDefaultStr(String.valueOf(param.getParams("page")), "1");
			vo.setParams("pageIndex", page);
			vo.setParams("pageSize", rows);
			Page pageList = logModelDetailManager.getPageInfo(vo);
			entity.setEntity(pageList);
		}
		entity.setMessage("查询成功");
		return entity;
	}

	public void setLogModelDetailManager(LogModelDetailManager logModelDetailManager) {
		this.logModelDetailManager = logModelDetailManager;
	}

}
